<script>
export default {
  name: "Home",
  data(){
    return{
      username:null,
      status:0//0是普通用户
    }
  },
  methods:{
    //根据id查找用户信息
    getUser(){
      var id = window.sessionStorage.getItem("id");
      //查询用户
      this.$http({url:"/user/selectId",method:"GET",params:{id:id}}).then(res=>{
        this.username = res.data.username
        this.status=res.data.status
      })
    },
    back(){
      window.sessionStorage.removeItem("token");
      window.sessionStorage.removeItem("id");
      this.$router.push("/")
    },
    get(){
      this.$router.push("/makemy")
    }
  },
  mounted() {//页面加载完成的方法//找用户
    this.getUser();
  },

}
</script>

<template>
  <el-container class="main-container">
    <el-header background-color="#ADD8E6">
      <div heigth="25px">
        <h1 style="float: left" >智能健康系统</h1>
        <div style="float: right">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="get">用户详情</el-dropdown-item>
              <el-dropdown-item @click.native="back">退出</el-dropdown-item><!--需要把存在当前的东西都删除掉-->
            </el-dropdown-menu>
          </el-dropdown>
          <span>{{ this.username }}</span>
        </div>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#ADD8E6"
          text-color="#fff"
          active-text-color="#ffd04b"
          router
          unique-opened
        >
          <el-menu-item index="/hello">首页面</el-menu-item>
          <el-submenu index="1" >
            <template slot="title">管理层</template>
            <el-menu-item index="/user">用户列表</el-menu-item>
            <el-menu-item index="/userhmanager">用户健康管理</el-menu-item>
            <el-menu-item index="/MakeMy">自己创造的</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">运动层</template>
            <el-menu-item index="/sportknlage">运动知识</el-menu-item>
            <el-menu-item index="/sportdetail">运动详情管理</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">健康层</template>
            <el-menu-item index="/userhealthput">用户健康上传</el-menu-item>
            <el-menu-item index="/healthvalue">健康评估</el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">智能体</template>
            <el-menu-item index="/test">医疗小卫士</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<style scoped>
.el-container{
  height: 100%;
}
.el-header, .el-footer {


  text-align: center;
  line-height: 60px;

}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;

}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;


}

body > .el-container {
  margin-bottom: 40px;
}
.main-container {
  background-image: url('../assets/login.jpg');
  background-size: cover; /* 自适应填充 */
  background-repeat: no-repeat;
}

</style>
